//
//  SchoolViewController.m
//  Civacrm
//
//  Created by 王桂敏 on 2017/2/6.
//  Copyright © 2017年 王桂敏. All rights reserved.
//

#import "SchoolViewController.h"
#import "LXMPieView.h"
#import "SchoolPageInfoModel.h"
#import "StudentDetailsViewController.h"
#import "SchoolLowCollectionViewCell.h"
#import "OrganizationViewController.h"
#import "SchoolViewTaskListModel.h"
#import "TeacherDetailsViewController.h"
#import "CourseDetailViewController.h"
#import "BottomView.h"
#import "WithoutDataTableViewCell.h"
#import "SchoolVipCollectionViewCell.h"
#import "TeacherVipCollectionViewCell.h"
#import "LessonCollectionViewCell.h"
#import "WithoutCollectionViewCell.h"
#import "SchoolHeaderCollectionReusableView.h"
@interface SchoolViewController ()<UICollectionViewDelegate,UICollectionViewDataSource>
@property (nonatomic, strong) UILabel *firstStudentLable;//学生数据
@property (nonatomic, strong) UILabel *firstMiddelStudentLable;
@property (nonatomic, strong) UILabel *hengLable;
@property (nonatomic, copy) NSString  *userString;
@property (nonatomic, copy) NSString  *lessonString;
@property (nonatomic, copy) NSString  *userImageViewString;
@property (nonatomic, copy) NSString  *lessonImageViewString;
@property (nonatomic, strong) SchoolPageInfoModel *schoolPageInfoModel;
@property (nonatomic, strong) NSMutableArray *userWeekStudentArray;
@property (nonatomic, strong) UICollectionView *collectionView;
@property (nonatomic, strong) NSMutableArray *schoolTaskArray;
@property (nonatomic, strong) NSMutableArray *courseDataSoure;
@property (nonatomic, strong) UIButton *lowButton ;
@property (nonatomic, strong) NSMutableArray *selectedArray;//是否被点击
@property (nonatomic, strong) UICollectionReusableView *headerView;
@end

@implementation SchoolViewController

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];

    //[self initNetWork];

    
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self initNetWork];
       self.title = @"我的机构";
    self.userWeekStudentArray = [[NSMutableArray alloc]init];
    self.schoolTaskArray = [[NSMutableArray alloc] init];
    self.courseDataSoure = [NSMutableArray array];
    [self initView];
    [self showIndeterminate];

    self.userString = @"显示全部";
    self.lessonString = @"显示全部";
    self.selectedArray = [NSMutableArray arrayWithObjects:@"0",@"0",@"0", nil];//这个用于判断展开还是缩回当前section的cell

    self.userImageViewString = @"icon_xiala";
    self.lessonImageViewString = @"icon_xiala";
}
- (void)initView{
    
    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc]init];


    layout.minimumInteritemSpacing = 0;
    layout.minimumLineSpacing = 1;
    self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0,0, self.view.width, self.view.height - 49 - 64 - h(80)) collectionViewLayout:layout];
    self.collectionView.backgroundColor = ClearColor;
    self.collectionView.delegate = self;
    self.collectionView.dataSource = self;
    self.collectionView.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);
    [self.collectionView registerClass:[SchoolHeaderCollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"header"];
    [self.collectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:@"footView"];
#warning 用静态变量标识cellID
    [self.collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"firstCell"];
    
    [self.collectionView registerClass:[SchoolLowCollectionViewCell class] forCellWithReuseIdentifier:@"item"];
    [self.collectionView registerClass:[SchoolVipCollectionViewCell class] forCellWithReuseIdentifier:@"item1"];
    [self.collectionView registerClass:[TeacherVipCollectionViewCell class] forCellWithReuseIdentifier:@"item2"];
    [self.collectionView registerClass:[LessonCollectionViewCell class] forCellWithReuseIdentifier:@"item3"];
    [self.collectionView registerClass:[WithoutCollectionViewCell class] forCellWithReuseIdentifier:@"withOut"];
    
    [self.view addSubview:self.collectionView];
    self.collectionView.mj_header = self.header;

    BottomView * bottomView = [BottomView initBottomViewWithFrame:CGRectMake(0, kScreenHeight - 49 - h(80) - 64, kScreenWidth, h(80)) andActivateNumString:self.activeString andPayForNumString:self.payforString];
    [self.view addSubview:bottomView];
    
}

- (void)handleHeaderRefreshingAction{
    
    [self initNetWork];
}
#pragma mark collectionView
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    if (self.userWeekStudentArray.count == 0) {
        return CGSizeMake(self.view.width, self.collectionView.height);
    }else{
        if (indexPath.section == 0) {
            return CGSizeMake(self.view.width, h(100));
        }
        else if(indexPath.section == 1){
            return  CGSizeMake(self.view.width/2 - w(1),h(365)); // 小图
        }else{
            return CGSizeMake(self.view.width, h(232));
        }
    }
    
    
}
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section
{
    if (section == 0) {
        
        
        return CGSizeMake(0, 0);
    }else{
        return CGSizeMake(self.view.width, h(62));
    }
}
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section
{
    
    return CGSizeMake(self.view.width, h(20));
}


- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath{
    UICollectionReusableView *reusableView =nil;
    NSArray *array = @[@"用户数据报表",@"课程进度报表"];
    if (kind == UICollectionElementKindSectionHeader) {
        SchoolHeaderCollectionReusableView *headerView = [collectionView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:@"header" forIndexPath:indexPath];
        headerView.backgroundColor = WhiteColor;
        
        headerView.button.tag = 1000 + indexPath.section;
        [headerView.button addTarget:self action:@selector(allButtonAction:) forControlEvents:UIControlEventTouchUpInside];
        
        NSArray *studentArray = @[self.userString,self.lessonString];
        NSArray *imageArray = @[self.userImageViewString, self.lessonImageViewString];
        headerView.imageView.image = Image(imageArray[indexPath.section - 1]);
        headerView.titleLable.text = array[indexPath.section - 1];
        headerView.studentLable.text = studentArray[indexPath.section - 1];
        reusableView = headerView;
        
    }else if (kind == UICollectionElementKindSectionFooter){
        UICollectionReusableView *footView = [collectionView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:@"footView" forIndexPath:indexPath];
        footView.backgroundColor = ClearColor;
        
        reusableView = footView;
        
    }
    return reusableView;
    
}
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
    
    if (self.userWeekStudentArray.count == 0) {
        return 1;
    }else{
        return 3;
    }
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    if (self.userWeekStudentArray.count == 0) {
        return 1;
    }else{
        if (section == 0) {
            return 1;
        }else if(section == 1){
            
            if ([self.selectedArray[section] isEqualToString:@"1"]) {
                return 4;
            }else{
                return 2;
            }
        }else{
            if (self.schoolTaskArray.count != 0) {
                
                if ([self.selectedArray[section] isEqualToString:@"1"]) {
                    return self.schoolTaskArray.count;
                }else{
                    return 1;
                }
            }else{
                return 0;
            }
        }
    }
    
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    if (self.userWeekStudentArray.count == 0) {
        WithoutCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"withOut"forIndexPath:indexPath];
        return cell;
        
    }else{
        self.schoolPageInfoModel = self.userWeekStudentArray[0];
        if (indexPath.section == 0) {
            UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"firstCell" forIndexPath:indexPath];
            cell.backgroundColor = WhiteColor;
#warning view视图复用时不要重复Add
            UILabel *lable = [cell viewWithTag:3333];
            if (!lable) {
                lable = [[UILabel alloc]init];
                [lable setTag:3333];
                [cell addSubview:lable];
            }
            UIImageView  *headerImageView = [cell viewWithTag:3334];
            if (!headerImageView) {
                headerImageView = [UIImageView imageViewWithFrame:CGRectMake(0, 0, w(34), h(34)) image:nil];
                headerImageView.contentMode =UIViewContentModeScaleAspectFill;
                [headerImageView setTag:3334];
                [lable addSubview:headerImageView];
            }
            UILabel *headerNameLable = [cell viewWithTag:3335];
            if (!headerNameLable) {
                headerNameLable = [UILabel labelWithTitle:self.orgName frame:CGRectMake(w(34)+ w(23),0,0,0) font:font(28) textColor:ColorWithHexString(@"407892") bgColor:ClearColor];
                [headerNameLable setTag:3335];
                [lable addSubview:headerNameLable];
            }

            //self.headerNameLable.centerY = lable.centerY;
            UIImageView *nextImageView = [cell viewWithTag:3336];
            if (!nextImageView) {
                nextImageView = [UIImageView imageViewWithFrame:CGRectMake(self.view.width - w(17)-w(17), 0, w(17), h(31)) image:@"icon_jinru3"];
                [nextImageView setTag:3336];
                [cell addSubview:nextImageView];
            }
            
            [headerImageView sd_setImageWithURL:[NSURL URLWithString:self.iconURL] placeholderImage:[UIImage imageNamed:@"icon_civazhicheng_active"]];
            headerNameLable.font = [UIFont fontWithName:@"Helvetica-Bold" size:((28 / 2) / kScreenHeight6) * kScreenHeight];
            [headerNameLable sizeToFit];
            headerImageView.centerY = headerNameLable.centerY;
            nextImageView.centerY = h(100)/2;
            lable.frame = CGRectMake(0, 0, headerImageView.width + w(23) + headerNameLable.width, h(34));
            lable.centerX = self.view.width/2;
            lable.centerY = w(100)/2;

            
            return cell;
        }else if(indexPath.section == 1 ){
            if (indexPath.row == 0) {
                NSMutableArray *modelArray = [NSMutableArray array];
                NSArray *stringStudent = @[@(self.schoolPageInfoModel.studentActivates),@(self.schoolPageInfoModel.studentCounts)];
                CGFloat studentFloat = 0;
                CGFloat studentVip = 0;
                if (self.schoolPageInfoModel.studentCounts != 0) {
                    studentVip = (CGFloat)self.schoolPageInfoModel.vipCounts/self.schoolPageInfoModel.studentCounts;
                    studentFloat = (CGFloat)(self.schoolPageInfoModel.studentActivates - self.schoolPageInfoModel.vipCounts)/self.schoolPageInfoModel.studentCounts;
                }
                
                NSArray *valueArray = @[ @(1- studentFloat - studentVip),@(studentFloat), @(studentVip)];
                NSArray *colorArray = @[ColorWithHexString(@"f6e5bd"),
                                        ColorWithHexString(@"edb463"),
                                        ColorWithHexString(@"f6e04b")];
#warning 数据添加不确定数据源大小，一律使用GCD处理
                for (int i = 0 ; i <valueArray.count ; i++) {
                    LXMPieModel *model = [[LXMPieModel alloc] initWithColor:colorArray[i] value:[valueArray[i] floatValue] text:nil];
                    [modelArray addObject:model];
                }
                
                NSArray *bigModelArray = @[modelArray];
                NSArray *bigColorArray = @[colorArray];
                NSArray *stringArray = @[stringStudent];
                
                NSArray *array =@[@"学生激活人数"];
                SchoolVipCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"item1" forIndexPath:indexPath];
                cell.backgroundColor = WhiteColor;
                cell.schoolPageInfoModel = self.schoolPageInfoModel;
                cell.studentLable.text = array[indexPath.item];
                cell.pieArray = bigModelArray[indexPath.item];
                cell.countArray = stringArray[indexPath.item];
                cell.colorArray = bigColorArray[indexPath.item];
                
                return cell;
            }
            else if ( indexPath.row == 2){
                NSMutableArray *modelArray = [NSMutableArray array];
                NSArray *stringStudent = @[@(self.schoolPageInfoModel.teacherActivates),@(self.schoolPageInfoModel.teacherCounts)];
                CGFloat studentFloat = 0;
                if (self.schoolPageInfoModel.studentCounts != 0) {
                    studentFloat = (CGFloat)self.schoolPageInfoModel.teacherActivates /self.schoolPageInfoModel.teacherCounts;
                }
                
                NSArray *valueArray = @[ @(1- studentFloat), @(studentFloat)];
                NSArray *colorArray = @[ColorWithHexString(@"def2fa"),
                                        ColorWithHexString(@"6dbfee")];
                for (int i = 0 ; i <valueArray.count ; i++) {
                    LXMPieModel *model = [[LXMPieModel alloc] initWithColor:colorArray[i] value:[valueArray[i] floatValue] text:nil];
                    [modelArray addObject:model];
                }
                
                NSArray *bigModelArray = @[modelArray];
                NSArray *bigColorArray = @[colorArray];
                NSArray *stringArray = @[stringStudent];
                
                NSArray *array =@[@"教师激活人数"];
                TeacherVipCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"item2" forIndexPath:indexPath];
                cell.backgroundColor = WhiteColor;
                cell.schoolPageInfoModel = self.schoolPageInfoModel;
                cell.studentLable.text = array[indexPath.item -2];
                cell.pieArray = bigModelArray[indexPath.item -2];
                cell.countArray = stringArray[indexPath.item -2];
                cell.colorArray = bigColorArray[indexPath.item -2];
                
                return cell;
                
            }else{
                NSMutableArray *modeArray = [NSMutableArray array];
                NSArray *stringStudent = @[@(self.schoolPageInfoModel.studentLoginCounts),@(self.schoolPageInfoModel.studentCounts)];
                CGFloat studentFloat = 0;
                if (self.schoolPageInfoModel.studentCounts != 0) {
                    studentFloat = (CGFloat)self.schoolPageInfoModel.studentLoginCounts/self.schoolPageInfoModel.studentCounts;
                }
                NSArray *valueArray = @[ @(1 - studentFloat), @(studentFloat)];
                NSArray *colorArray = @[ColorWithHexString(@"efdbee"),
                                        ColorWithHexString(@"c692c4")];
                for (int i = 0 ; i <valueArray.count ; i++) {
                    LXMPieModel *model = [[LXMPieModel alloc] initWithColor:colorArray[i] value:[valueArray[i] floatValue] text:nil];
                    [modeArray addObject:model];
                }
                
                NSMutableArray *model1Array = [NSMutableArray array];
                CGFloat teacherFloat = 0;
                if (self.schoolPageInfoModel.teacheloginCounts != 0) {
                    teacherFloat = (CGFloat)self.schoolPageInfoModel.teacheloginCounts/(CGFloat)self.schoolPageInfoModel.teacherCounts;
                }
                NSArray *stringTeacher = @[@(self.schoolPageInfoModel.teacheloginCounts),@(self.schoolPageInfoModel.teacherCounts)];
                NSArray *value1Array = @[ @(1- teacherFloat), @(teacherFloat)];
                NSArray *color1Array = @[ColorWithHexString(@"dbecd6"),
                                         ColorWithHexString(@"95ca85")];
                
                for (int i = 0 ; i <value1Array.count ; i++) {
                    LXMPieModel *model = [[LXMPieModel alloc] initWithColor:color1Array[i] value:[value1Array[i] floatValue] text:nil];
                    [model1Array addObject:model];
                }
                NSArray *bigModelArray = @[modeArray,model1Array];
                NSArray *bigColorArray = @[colorArray,color1Array];
                NSArray *stringArray = @[stringStudent,stringTeacher];
                
                NSArray *array =@[@"今日学生登录人数", @"今日教师登录人数"];
                SchoolLowCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"item" forIndexPath:indexPath];
                cell.backgroundColor = WhiteColor;
                cell.schoolPageInfoModel = self.schoolPageInfoModel;
                cell.studentLable.text = array[indexPath.item/2];
                cell.pieArray = bigModelArray[indexPath.item/2];
                cell.countArray = stringArray[indexPath.item/2];
                cell.colorArray = bigColorArray[indexPath.item/2];
                
                
                
                return cell;
                
            }
        }else{
            SchoolViewTaskListModel *model = self.schoolTaskArray[indexPath.item];
            NSMutableArray *modeArray = [NSMutableArray array];
            CGFloat leassonFloat = 0;
            NSArray *stringStudent = @[@(model.count),@([model.subTaskNum intValue])];
            //            NSString *stringStudent = [NSString stringWithFormat: @"%ld/%@",model.count,model.subTaskNum];
            //    NSString *lesonCount = [NSString stringWithFormat: @"%ld",model.count];
            if (model.subTaskNum != 0) {
                leassonFloat = (CGFloat)model.count/[model.subTaskNum intValue];
            }
            
            NSArray *valueArray = @[ @(1- leassonFloat), @(leassonFloat)];
            NSArray *colorArray = @[ColorWithHexString(@"def2fa"),
                                    ColorWithHexString(@"41c3ff")];
            for (int i = 0 ; i <valueArray.count ; i++) {
                LXMPieModel *model = [[LXMPieModel alloc] initWithColor:colorArray[i] value:[valueArray[i] floatValue] text:nil];
                [modeArray addObject:model];
            }
            
            NSArray *bigModelArray = @[modeArray];
            NSArray *bigColorArray = @[colorArray];
            NSArray *stringArray = @[stringStudent];
            
            LessonCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"item3" forIndexPath:indexPath];
            cell.backgroundColor = WhiteColor;
            cell.civaLesonLable.text = model.taskName;
            cell.civaLesonCountLable.text = [NSString stringWithFormat:@"已完成%ld步 / 共%@步",model.count,model.subTaskNum];
            cell.schoolPageInfoModel = model;
            cell.countArray = stringArray[0];
            
            cell.pieArray = bigModelArray[0];
            cell.colorArray = bigColorArray[0];
            
            return cell;
        }
    }
    
    
    
}
#pragma mark buttonAction{
- (void)allButtonAction:(UIButton *)button{
    NSLog(@"1");
    if ([self.selectedArray[button.tag - 1000] isEqualToString:@"0"]) {
        
        //                for (NSInteger i = 0; i < _sectionArray.count; i++) {
        //                    [_selectedArray replaceObjectAtIndex:i withObject:@"0"];
        //                    [_tableView reloadSections:[NSIndexSet indexSetWithIndex:i] withRowAnimation:UITableViewRowAnimationFade];
        //                }
        
        
        //如果当前点击的section是缩回的,那么点击后就需要把它展开,是_selectedArray对应的值为1,这样当前section返回cell的个数就变为真实个数,然后刷新这个section就行了
        if (button.tag - 1000 == 1) {
            self.userString = @"显示局部";
            
            self.userImageViewString = @"icon_shangla";
        }else if(button.tag -1000 == 2){
            self.lessonString = @"显示局部";
            self.lessonImageViewString = @"icon_shangla";
            
            
        }
        [self.selectedArray replaceObjectAtIndex:button.tag - 1000 withObject:@"1"];
        
        [UIView performWithoutAnimation:^{
            [self.collectionView reloadSections:[NSIndexSet indexSetWithIndex:button.tag - 1000]];
        }];
    }
    else
    {
        //如果当前点击的section是展开的,那么点击后就需要把它缩回,使_selectedArray对应的值为0,这样当前section返回cell的个数变成0,然后刷新这个section就行了
        if (button.tag - 1000 == 1) {
            self.userString = @"显示全部";
            self.userImageViewString = @"icon_xiala";
            
        }else if(button.tag -1000 == 2){
            self.lessonString = @"显示全部";
            self.lessonImageViewString = @"icon_xiala";
            
        }
        
        [self.selectedArray replaceObjectAtIndex:button.tag - 1000 withObject:@"0"];
        [UIView performWithoutAnimation:^{
            
            [self.collectionView  reloadSections:[NSIndexSet indexSetWithIndex:button.tag - 1000]];
        }];
        
    }
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
    if (self.userWeekStudentArray.count == 0) {
        [self initNetWork];
    }else{
        if (indexPath.section == 0) {
            //机构详情页
            OrganizationViewController *sdVC = [[OrganizationViewController alloc] init];
            [self.navigationController pushViewController:sdVC animated:YES];
            
        }else if (indexPath.section == 1){
            //学生详情页
            if (indexPath.row == 0) {
                
                StudentDetailsViewController *sdVC = [[StudentDetailsViewController alloc] init];
                sdVC.schoolPageInfoModel = self.schoolPageInfoModel;
                [self.navigationController pushViewController:sdVC animated:YES];
            }else if (indexPath.row == 2){
                //教师详情页
                TeacherDetailsViewController *tdVC =[[TeacherDetailsViewController alloc]init];
                tdVC.schoolPageInfoModel = self.schoolPageInfoModel;
                
                [self.navigationController pushViewController:tdVC animated:YES];
                
            }
            
            
        }else{
            //课程详情页
            CourseDetailViewController *VC = [[CourseDetailViewController alloc] init];
            VC.webURL = [NSString stringWithFormat:@"%@&uId=%@&taskId=%@",H5url,self.userID,[[self.courseDataSoure[indexPath.row] taskModel] taskId]];
            VC.model = self.courseDataSoure[indexPath.row];
            [self.navigationController pushViewController:VC animated:YES];
            
        }
    }
}

#pragma mark netWork
- (void)initNetWork{
    //
    self.params[@"uId"] = self.userID;
    //    self.userID = @"6d40e15e-7433-416f-9d9b-13299ea4f411";
//    [self showIndeterminate];
    [self.manager postWithURL:NET_GETSCHOOLINFO param:self.params delegate:self isEncrypt:NO type:NetWorkingType0];
    
}
- (void)networkingHandleSuccess:(NetworkingHandle *)handle parameters:(NSDictionary *)parameters responseObject:(id)responseObject type:(NetWorkingType)type{
    [self hideHud];
    [self.collectionView.mj_header endRefreshing];

    switch (type) {
        case NetWorkingType0:
        {

            [self.lowButton removeFromSuperview];
            NSArray *array  = [responseObject objectForKey:@"schoolPageInfo"];
            if (self.userWeekStudentArray.count) {
                [self.userWeekStudentArray removeAllObjects];
            }
            for (NSDictionary *dic in array) {
                SchoolPageInfoModel *model = [[SchoolPageInfoModel alloc] init];
                [model setValuesForKeysWithDictionary:dic];
              
                [self.userWeekStudentArray addObject:model];
            }
            NSArray *lowArray  = [responseObject objectForKey:@"taskList"];
            NSDictionary *taskArray =[NSMutableDictionary dictionary];
            if (self.schoolTaskArray.count) {
                [self.schoolTaskArray removeAllObjects];
            }
            if (self.courseDataSoure.count) {
                [self.courseDataSoure removeAllObjects];
            }

            for (NSDictionary *dic in lowArray) {
                taskArray = [dic objectForKey:@"task"];
                SchoolViewTaskListModel *model = [[SchoolViewTaskListModel alloc] init];
                [model setValuesForKeysWithDictionary:taskArray];
                [self.schoolTaskArray addObject:model];
                CourseModel *courseModel = [[CourseModel alloc] init];
                [courseModel setValuesForKeysWithDictionary:dic];
                [self.courseDataSoure addObject:courseModel];
            }
            
            [self.collectionView reloadData];
        }
            break;
            
        default:
            break;
    }
    
    
    
}

- (void)networkingHandlefail:(NetworkingHandle *)handle type:(NetWorkingType)type{
    [self hideHud];
    [self.collectionView.mj_header endRefreshing];

    //    switch (type) {
    //        case NetWorkingType0:{
    //            self.lowButton = [UIButton buttonOfImageForNormalWithImage:nil frame:self.view.frame target:self action:@selector(initNetWork)];
    //            UIImageView  *imageview = [UIImageView imageViewWithFrame:CGRectMake(0, h(250), w(290), h(331)) image:@"bg_zanwushuju"];
    //            [self.lowButton addSubview:imageview];
    //            imageview.centerX = self.lowButton.centerX;
    //
    //            [self.view addSubview:self.lowButton];
    //        }
    //
    //            break;
    //
    //        default:
    //            break;
    //    }
}

- (void)networkingHandleWarning:(NetworkingHandle *)handle responseObject:(id)responseObject type:(NetWorkingType)type{
    [self hideHud];
    [self.collectionView.mj_header endRefreshing];

    //    switch (type) {
    //        case NetWorkingType0:{
    //            self.lowButton= [UIButton buttonOfImageForNormalWithImage:nil frame:self.view.frame target:self action:@selector(initNetWork)];
    //            UIImageView  *imageview = [UIImageView imageViewWithFrame:CGRectMake(0, h(250), w(290), h(331)) image:@"bg_zanwushuju"];
    //            [self.lowButton addSubview:imageview];
    //            imageview.centerX = self.lowButton.centerX;
    //            [self.view addSubview:self.lowButton];
    //
    //        }
    //
    //            break;
    //
    //        default:
    //            break;
    //    }
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
